package com.logicalthinking.socialmall.controller.app;

import com.github.chenlijia1111.utils.common.Result;
import com.github.chenlijia1111.utils.core.annos.PropertyCheck;
import com.logicalthinking.socialmall.biz.ClientUserBiz;
import com.logicalthinking.socialmall.common.vo.requestVo.clientUser.CertificateRegForPersonParams;
import com.logicalthinking.socialmall.common.vo.requestVo.clientUser.CertificateRegForShopParams;
import com.logicalthinking.socialmall.common.vo.requestVo.clientUser.WechatLoginParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 客户端用户
 * <p>
 * 普通用户注册只需要微信信息即可,没有认证就没有手机号信息,通过微信信息可以获取到微信昵称性别等信息
 * <p>
 * 个人认证以及商家认证后会输入手机号等信息
 *
 * @author chenLiJia
 * @since 2020-02-17 14:43:59
 **/
@RestController("appClientUserController")
@RequestMapping(value = "app/clientUser")
@Api(tags = "客户端用户管理")
@PropertyCheck
public class ClientUserController {

    @Autowired
    private ClientUserBiz biz;//客户端用户


    /**
     * 获取微信openId
     * 根据微信code 进行登录
     * 如果用户不存在则创建用户
     *
     * @param wechatCode
     * @return
     */
    @PostMapping(value = "wechatLogin/code")
    @ApiOperation(value = "通过code微信登陆", notes = "如果用户已注册,会直接返回token在response的header中")
    public Result wechatLogin(String wechatCode) {
        return biz.wechatLogin(wechatCode);
    }

    /**
     * 微信登陆
     *
     * @param params
     * @return
     */
    @Deprecated
    @ApiOperation(value = "微信登陆", notes = "token在response的header中")
    public Result wechatLogin(WechatLoginParams params) {
        return biz.wechatLogin(params);
    }

    /**
     * 个人认证注册
     *
     * @param params
     * @return
     */
    @PostMapping(value = "certificate/reg/person")
    @ApiOperation(value = "个人认证注册")
    public Result certificateRegForPerson(CertificateRegForPersonParams params) {
        return biz.certificateRegForPerson(params);
    }

    /**
     * 商家认证注册
     *
     * @param params
     * @return
     */
    @PostMapping(value = "certificate/reg/shop")
    @ApiOperation(value = "商家认证注册")
    public Result certificateRegForShop(CertificateRegForShopParams params) {
        return biz.certificateRegForShop(params);
    }

}
